/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.dto.AppAskNoticeDto;
import com.icinfo.cloud.provider.punish.dto.DocumentRecordQueryDto;
import com.icinfo.cloud.provider.punish.dto.SimpleCaseSignFileIdSaveDto;
import com.icinfo.cloud.provider.punish.dto.SimpleCaseSignSaveDto;
import com.icinfo.cloud.provider.punish.service.ICaseDocumentRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseDocumentRecordDelRequest;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseDocumentRecord;
import com.icinfo.cloud.provider.punish.vo.AppAskNoticeDocumentVo;
import com.icinfo.cloud.provider.punish.vo.CaseDocumentRecordSimpleVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import com.icinfo.framework.tools.utils.MapUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 【掌上办案V1.1】  描述: app端 文书记录表操作前端控制器
 *
 * @author framework generator
 * @date 2022年02月15日
 */
@RestController
@RefreshScope
@RequestMapping("/app/main/document")
@Slf4j
public class CaseDocumentRecordController extends BaseController {

    @Resource
    private ICaseDocumentRecordService caseDocumentRecordService;
    /*@Resource
    private PunishCaseFeignClient punishCaseFeignClient;*/


    /**
     * 描述： 根据caseId查询关联文书列表
     *
     * @author: zhengqiang
     * @date: 2022/6/21
     * @param: caseId
     * @return {@link Result< List< CaseDocumentRecord>>}
     **/
    @PostMapping("/getDocumentRecordByCaseId")
    public Result<List<CaseDocumentRecordSimpleVo>> getDocumentRecordByCaseId(@RequestBody @Validated DocumentRecordQueryDto queryDto) {
        List<CaseDocumentRecordSimpleVo> documentRecords = caseDocumentRecordService.getDocumentRecordByCaseId(queryDto.getCaseId());
        return Result.success(documentRecords);
    }

    /**
     * 简易处罚接受签字捺印
     *
     * @author: zhengqiang
     * @date: 2022/6/16
     * @param: saveDto
     * @return {@link Result}
     **/
    @PostMapping("/receiveSignFileOfCaseDoc")
    public Result receiveSignFileOfCaseDoc(@RequestBody @Validated SimpleCaseSignSaveDto saveDto) {
        Map<String, Object> resultMap = caseDocumentRecordService.receiveSignFileOfSimple(saveDto);
        String status = MapUtils.getString(resultMap, "success","");
        String t = "true";
        if (t.equals(status)) {
            return Result.success(Constant.STRING_SAVE_SUCCESS,resultMap);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 简易处罚接受签字捺印, 重庆
     *
     **/
    @PostMapping("/receiveSignFileIdOfCaseDoc")
    public Result receiveSignFileIdOfCaseDoc(@RequestBody @Validated SimpleCaseSignFileIdSaveDto saveDto) {
        Map<String, Object> resultMap = caseDocumentRecordService.receiveSignFileIdOfCaseDocChongQing(saveDto);
        String status = MapUtils.getString(resultMap, "success","");
        String t = "true";
        if (t.equals(status)) {
            return Result.success(Constant.STRING_SAVE_SUCCESS,resultMap);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 文书删除
     * @author liyafeng
     * @date 2023/1/12
     * @param caseDocumentRecordDelRequest
     * @return {@link Result< String>}
     */
    @PostMapping("/delCaseDocumentRecordInfo")
    public Result<String> delCaseDocumentRecordInfo(@RequestBody @Validated CaseDocumentRecordDelRequest caseDocumentRecordDelRequest) {
        return caseDocumentRecordService.delCaseDocumentRecordInfo(caseDocumentRecordDelRequest);
    }

    /**
     * 【V1.11.0】描述：抽样取证物品处理通知书查询抽象取证通知书接口
     *
     * @param appAskNoticeDto 抽样取证dto
     * @return {@link Result<  AppAskNoticeDocumentVo  > }
     * @author ljy
     * @date 2023/02/21
     */
    @PostMapping("/getAppAskNoticeDocumentDetail")
    @ApiOperation(value = "【V1.0.0】描述：抽样取证物品处理通知书查询抽象取证通知书接口", httpMethod = "POST")
    public Result<List<AppAskNoticeDocumentVo>> getAppAskNoticeDocumentDetail(@RequestBody @Validated AppAskNoticeDto appAskNoticeDto) {
        return Result.success(Constant.STRING_GET_SUCCESS,caseDocumentRecordService.getAppAskNoticeDocumentDetail(appAskNoticeDto));
    }

}
